﻿@model IEnumerable<Data.Model.AppLibrary>
@{
    ViewBag.Title = "List";
}
<form method="post" id="form1" >
<div class="querybar">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td>
                应用名称：<input type="text" class="mytext" id="Title" name="title1" value="@ViewBag.Title1" style="width:180px" />
                应用地址：<input type="text" class="mytext" id="Address" name="address" value="@ViewBag.Address" style="width:220px" />
                <input type="submit" name="Search" value="查询" class="mybutton" />
            </td>
        </tr>
    </table>
</div>
<div class="toolbar" style="margin-top:0; border-top:0;">
    <a href="javascript:void(0);" onclick="add();return false;"><span style="background-image:url(@Url.Content("~/Images/ico/folder_classic_stuffed_add.png"));">添加应用</span></a>
    <span class="toolbarsplit">&nbsp;</span>
    <a href="javascript:void(0);" onclick="del();return false;"><span style="background-image:url(@Url.Content("~/Images/ico/folder_classic_stuffed_remove.png"));">删除所选</span></a>
</div>
<table cellpadding="0" cellspacing="1" border="0" class="listtable">
    <thead>
        <tr>
            <th><input type="checkbox" onclick="checkAll(this.checked);" style="vertical-align:middle;" />应用名称</th>
            <th>应用地址</th>
            <th>应用分类</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
    @{
    Business.Platform.Dictionary bdict = new Business.Platform.Dictionary();
    foreach (var app in Model)
    {
        <tr>
            <td><input type="checkbox" value="@app.ID" name="checkbox_app" />@app.Title</td>
            <td>@app.Address</td>
            <td>@bdict.GetTitle(app.Type)</td>
            <td><a class="editlink" href="javascript:void(0);" onclick="edit('@app.ID');return false;">编辑</a></td>
        </tr>
    }    
    }
    </tbody>
</table>
<div class="buttondiv">@Html.Raw(ViewBag.Pager)</div>
</form>

<script type="text/javascript">
    var appid = '@ViewBag.AppID';
    var iframeid = '@ViewBag.TabID';
    var typeid = '@ViewBag.TypeID';
    var dialog = top.mainDialog;
    var rootdir = '@Url.Content("~/")';
    function add()
    {
        dialog.open({ id: "window_" + appid.replaceAll('-', ''), title: "添加应用程序", width: 700, height: 350, url: rootdir + 'AppLibrary/Edit?1=1' + '@ViewBag.Query1', openerid: iframeid });
    }
    function edit(id)
    {
        dialog.open({ id: "window_" + appid.replaceAll('-', ''), title: "编辑应用程序", width: 700, height: 350, url: rootdir + 'AppLibrary/Edit?id=' + id + '@ViewBag.Query1', openerid: iframeid });
    }
    function checkAll(checked)
    {
        $("input[name='checkbox_app']").prop("checked", checked);
    }
    function del()
    {
        if ($(":checked[name='checkbox_app']").size() == 0)
        {
            alert("您没有选择要删除的项!");
            return false;
        }
        if (!confirm('您真的要删除所选应用吗?'))
        {
            return false;
        }
        $("#form1").attr("action", "Delete"+"@Html.Raw(Request.Url.Query)");
        $("#form1").submit();
        return true;
    }
</script>